package club.xyes.zkh.ecommerce.wechat.dto;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

/**
 * Create by 郭文梁 2019/4/19 0019 13:23
 * SaoBeiPayResult
 * 扫呗小程序支付返回结果
 *
 * @author 郭文梁
 * @data 2019/4/19 0019
 */
@Data
public class SaoBeiPayResult {
    public static final String RESULT_CODE_SUCCESS = "01";

    /**
     * 从JSON中创建该对象
     *
     * @param json json
     * @return 结果对象
     */
    public static SaoBeiPayResult fromJsonString(String json) {
        SaoBeiPayResult res = JSON.parseObject(json, SaoBeiPayResult.class);
        res.sourceJson = json;
        return res;
    }

    @JSONField(name = "return_code")
    private String returnCode;
    @JSONField(name = "return_msg")
    private String returnMsg;
    @JSONField(name = "result_code")
    private String resultCode;
    @JSONField(name = "pay_type")
    private String payType;
    @JSONField(name = "merchant_name")
    private String merchantName;
    @JSONField(name = "merchant_no")
    private String merchantNo;
    @JSONField(name = "terminal_id")
    private String terminalId;
    @JSONField(name = "terminal_trace")
    private String terminalTrace;
    @JSONField(name = "terminal_time")
    private String terminalTime;
    @JSONField(name = "total_fee")
    private String totalFee;
    @JSONField(name = "out_trade_no")
    private String outTradeNo;
    @JSONField(name = "ali_trade_no")
    private String aliTradeNo;
    private String appId;
    private String timeStamp;
    private String nonceStr;
    @JSONField(name = "package_str")
    private String packageStr;
    private String signType;
    private String paySign;
    @JSONField(name = "token_id")
    private String tokenId;
    @JSONField(name = "redirect_uri")
    private String redirectUri;
    @JSONField(name = "front_notify_url")
    private String frontNotifyUrl;
    @JSONField(name = "key_sign")
    private String keySign;
    private String jdParams;
    private String bestpayParams;
    /**
     * 用于保存源JSON
     */
    private String sourceJson;

    /**
     * 是否成功
     *
     * @return 是否成功
     */
    public boolean isSuccess() {
        return RESULT_CODE_SUCCESS.equals(resultCode);
    }
}
